#ifndef __WD_TASKQUEUE_H__
#define __WD_TASKQUEUE_H__

#include <pthread.h>
#include "mysql_op.h"

#define TASKQUEUE_NOT_EXIT_FLAG 0
#define TASKQUEUE_READY_EXIT_FLAG 1

typedef enum
{
	CMD_TYPE_CD = 1,
	CMD_TYPE_LS = 2,
	CMD_TYPE_PWD = 4,
	CMD_TYPE_PUT = 8,
	CMD_TYPE_GET = 16,
	CMD_TYPE_RM = 32,
	CMD_TYPE_MKDIR = 64,
	CMD_TYPE_LOGIN = 128,
	CMD_TYPE_REG = 256
}CmdType;

typedef struct task_s
{
	int peerfd;
	CmdType type;
	int usrid;//用户id,分开不同用户的命令
	char data[1024];//现在可以传输文件，所以扩充大小.考虑分开长短命令,避免浪费空间
	struct task_s *pnext;
}task_t;

typedef struct taskqueue_s{
	task_t * pFront;
	task_t * pRear;
	int queSize;
	int exitFlag;//退出的标志位
	pthread_mutex_t mutex;
	pthread_cond_t cond;
} task_queue_t;

void queueInit(task_queue_t *);
void queueDestroy(task_queue_t*);
int queueIsEmpty(task_queue_t *);
int getTaskSize(task_queue_t *);
void taskEnqueue(task_queue_t*,task_t* ptask);
task_t* taskDequeue(task_queue_t * que);
void queueWakeup(task_queue_t*);
 
#endif
